#ifndef GTRANS_H
#define GTRANS_H

#include <QWidget>
#include <QSqlDatabase>
#include <QSqlQueryModel>
#include <QSqlQuery>
#include <QSqlTableModel>
#include <QModelIndex>

#include <moneydelegate.h>
#include <qmodeldatareport.h>

#include <QMessageBox>
#include <QInputDialog>
#include <QProgressDialog>
#include <QFileDialog>
#include <QSettings>

#include <QtDebug>
#include <QSqlError>


namespace Ui {
class GTrans;
}

class GTrans : public QWidget
{
    Q_OBJECT

public:
    explicit GTrans(QString connexionName,int id = 0 ,QWidget *parent = 0);
    ~GTrans();

    void activerCommandesRemise(bool checked);
    void connecterTemp();

private slots:

    //Tab transactions
    void on_groupTransDetailFiltre_toggled(bool arg1);
    void on_buttonTransDetailFiltre_clicked();
    void on_spinTransDetailsConcerne_valueChanged(int arg1);
    void on_spinTransDetailsEt_valueChanged(int arg1);
    void on_spinTransNewDepuis_valueChanged(int arg1);
    void on_spinTransNewVers_valueChanged(int arg1);
    void on_buttonTransNewAnnuler_clicked();
    void on_buttonTransNewValider_clicked();
    void on_buttonTransDetailImprimer_clicked();
    void sommeSelectionnee();

    //Tab Remise
    void on_buttonRemiseFermer_clicked();
    void on_buttonRemiseNouveau_clicked();
    void on_buttonRemiseOuvrir_clicked();
    void on_tableRemiseNouveaux_clicked(const QModelIndex &index);
    void on_spinRemiseAjoutFams_valueChanged(int arg1);
    void on_comboRemiseAjoutProms_currentTextChanged(const QString &arg1);
    void on_spinRemiseAjoutMontant_editingFinished();
    void on_buttonRemiseAjoutAutre_clicked();
    void on_checkRemiseAjoutPartage_toggled(bool checked);
    void on_buttonRemiseAjoutCompte_clicked();
    void on_tableRemiseAjoutPartage_clicked(const QModelIndex &index);
    void on_buttonRemiseAjoutSupprimer_clicked();
    void on_buttonRemiseAjoutAnnuler_clicked();
    void on_buttonRemiseAjoutValider_clicked();
    void on_buttonRemiseImprimer_clicked();
    void on_buttonRemiseAppliquer_clicked();

    //Tab Param
    void on_buttonParamConnexionModifier_clicked();
    void on_buttonParamConnexionAnnuler_clicked();
    void on_buttonParamBanqueAjouter_clicked();
    void on_buttonParamBanquesRetirer_clicked();
    void on_spinParamCompteFams_valueChanged(int arg1);
    void on_buttonParamCompteModifier_clicked();
    void on_buttonParamCompteAnnuler_clicked();

    //Tab Agios
    void raffraichirApercuAgios();
    void majCompteurs();
    void modifSelection(const QItemSelection & selected, const QItemSelection & deselected);
    void on_buttonAgiosCommandesAppliquer_clicked();
    void on_buttonAgiosApercu_clicked();
    void on_buttonAgiosPromsRaffraichir_clicked();


private:
    Ui::GTrans *ui;

    QSqlDatabase db;
    int idConnexion;

    //Tab transactions
    QSqlTableModel *modelTransactions;

    //Tab remise
    QSqlDatabase dbRemise;
    QString cheminBase;
    QSqlTableModel *modelRemise;
    QSqlTableModel *modelRemiseDetail;
    int idRemiseSelected;
    QString nomtmp;
    QString prenomtmps;

    //Tab Agios
    QSqlQueryModel *modelAgiosComptes;
    QSqlQueryModel *modelAgiosProms;
    QList<int> listExempts;
    QString requeteBaseAgios;
    int nbComptesAgios;
    bool isReloading;

};

#endif // GTRANS_H
